package il.ac.bgu.cs.heuristics.graph.pddl;

import il.ac.bgu.cs.heuristics.graph.pddl.parser.types.AbstractParameter;
import il.ac.bgu.cs.heuristics.graph.pddl.parser.types.BoundParameter;
import il.ac.bgu.cs.heuristics.graph.pddl.parser.types.ITypedConstant;

/**
 * Performs sensitive cast operations without silencing conversion errors
 * 
 * @author Ronen Pinko
 * 
 */
public final class SafeCast{

	private SafeCast() {
	} // no instantiation

	public static ITypedConstant toTypedConstant(AbstractParameter parameter) {
		if (parameter instanceof BoundParameter) {
			return (ITypedConstant) parameter;
		} else {
			throw new ClassCastException("misuse of ITypedConstant interface");
		}
	}
	
	public static BoundParameter toBoundParameter(ITypedConstant constant){
		if (constant instanceof BoundParameter){
			return (BoundParameter) constant;
		}else{
			throw new ClassCastException("misuse of ITypedConstant interface");
		}
	}

}
